/*
    请求地址：http://wthrcdn.etouch.cn/weather_mini
    请求方式：get
    请求参数：city(城市名)
    响应内容：天气消息

    1.点击回车
    2.查询数据
    3.渲染数据
*/
var vue = new Vue({
    el: "#app",
    data: {
        city: '',
        logo: "Logo",
        weatherList: []
    },
    methods: {
        //回车搜索天气
        searchWeather: function () {
            // console.log("天气查询")
            // console.log(this.city)
            //调用接口
            //保存this
            var that = this;
            axios.get("http://wthrcdn.etouch.cn/weather_mini?city=" + this.city)
                .then(function (response) {
                    console.log(response.data);
                    that.weatherList = response.data.data.forecast;
                    that.logo = response.data.data.city;
                }, function (err) {
                    console.log(err)
                })
        },
        changeCity: function (city) {
            this.city = city;
            this.searchWeather();
        }
    }
})
